package org.csu.mypetstore.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.aspectj.lang.annotation.Around;
import org.csu.mypetstore.commonResponse.CommonResponse;
import org.csu.mypetstore.domin.Address;
import org.csu.mypetstore.domin.LogTable;
import org.csu.mypetstore.persistence.LogTableMapper;
import org.csu.mypetstore.service.LogTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("logTableService")

public class LogTableServiceImpl implements LogTableService {

    @Autowired
    LogTableMapper logTableMapper;
    @Override
    public CommonResponse<List<LogTable>> getLogTableListByUsername(String username) {
        QueryWrapper<LogTable> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("username",username);
        List<LogTable> logTableList=logTableMapper.selectList(queryWrapper);
        if(logTableList==null){
            return CommonResponse.createForError("通过username查找日志失败");
        }
        return CommonResponse.createForSuccess("查找成功",logTableList);
    }

    @Override
    public CommonResponse<LogTable> addLogTable(LogTable logTable) {
        int x=logTableMapper.insert(logTable);
        if(x==0){
            return CommonResponse.createForError("增加日志失败");
        }
        return CommonResponse.createForSuccess("增加成功",logTable);
    }

}
